<extend name="Public/baseConf"/>  
<block name="breadcrumb"> 
	<div class="row wrapper border-bottom white-bg page-heading">
	    <div class="col-lg-10">
	        <h2>产品管理
	        <small>
	        	<present name="Think.get.categoryno">
			         <a href="{:U('index')}"><span class='btn btn-sm btn-white btn-round'>全部</span></a>
			         <else/>
			         <span class='btn btn-sm btn-info btn-round'>全部</span>
		        </present>&nbsp;
		        <foreach name="_catelist" item="vo">
					 <neq name="category_id" value="$vo.id">
			         <a href="{:U('index?categoryno='.$vo['id'])}"><span class='btn btn-sm btn-white btn-round'>{$vo.name}</span></a>
			         <else/>
			         <span class='btn btn-sm btn-info btn-round'>{$vo.name}</span>
			         </neq>&nbsp;     
		        </foreach>
        	</small>
	        </h2>
	        <ol class="breadcrumb">
	            <li><a href="{:U('index/index')}">首页</a></li>
	            <li class="active">
	                <strong><if condition="$data eq null">新增产品<else/>编辑产品({$data['productname']})</if></strong>
	            </li>
	        </ol>
	    </div>
	    <div class="col-lg-2">
            <div class="title-action">
           		<button class="btn btn-primary ajax-post" type="submit" target-form="form-horizontal">
           		<i class="fa fa-pencil align-top"></i>确定
           		</button> 
            </div>
        </div>
	</div> 
</block>
<block name="body">
	<div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
	        <div class="col-lg-12">
	            <div class="ibox float-e-margins">
	                <div class="ibox-title">
	                    <h5>新增产品信息</h5>
	                    <div class="ibox-tools">
	                        <a class="collapse-link">
	                            <i class="fa fa-chevron-up"></i>
	                        </a>
	                    </div>
	                </div>
	                <div class="ibox-content">
		                <form action="{:U('savePicShow')}" method="post"  class="form-horizontal" role="form">
		                
								<input type="hidden" name="path" id="path" value="{$data['path']}"/>
								<input type="hidden" name="bigpath" id="bigpath" value="{$data['bigpath']}"/>
		                    <div class="row">
		                    	<input type="hidden" name="id" value="{$data['id']}"/>
		                        <div class="col-sm-4 b-r">
	                                <div class="input-group">
	                                    <span class="input-group-btn">
	                                        <button class="btn btn-info" type="button">商品</button>
	                                    </span>
		                                <input type="text" id="productname" name="productname" value="{$data['productname']}" placeholder="必填项" class="form-control">
		                            </div>
	                                <div class="input-group">
	                                    <span class="input-group-btn">
	                                        <button class="btn btn-info" type="button">品牌</button>
	                                    </span>
		                                <input type="text" id="brandname" name="brandname" value="{$data['brandname']}" class="form-control">
		                            </div>
	                                <div class="input-group">
	                                    <span class="input-group-btn">
	                                        <button class="btn btn-info" type="button">描述</button>
	                                    </span>
		                                <input type="text" id="introduce" name="introduce" value="{$data['introduce']}" class="form-control">
		                            </div>
	                                
		                        </div>
		                        <div class="col-sm-4 b-r">
	                                <div class="input-group">
	                                    <span class="input-group-btn">
	                                        <button class="btn btn-info" type="button">分类</button>
	                                    </span>
	                                    <select id="category" name="category" class="form-control">
											<volist name="_catelist" id="catevo">
												<option value="{$catevo.name}" <eq name="data['category']" value="$catevo.name">selected</eq>>{$catevo.name}</option>
											</volist>
										</select>
	                                </div>
	                                <div class="input-group">
	                                    <span class="input-group-btn">
	                                        <button class="btn btn-info" type="button">库存</button>
	                                    </span>
		                                <input type="text" id="stock" name="stock" value="{$data['stock']}" class="form-control">
		                            </div>
		                        </div>
		                        <div class="col-sm-4">
	                                <div class="input-group">
	                                    <span class="input-group-btn">
	                                        <button class="btn btn-info" type="button">价格</button>
	                                    </span>
		                                <input type="text" id="price" name="price" value="{$data['price']}" class="form-control">
		                            </div>
	                                <div class="input-group">
	                                    <span class="input-group-btn">
	                                        <button class="btn btn-info" type="button">链接</button>
	                                    </span>
		                                <input type="text" id="url" name="url" value="{$data['url']}" class="form-control">
		                            </div>
		                        </div>
		                    </div>
		                    <div class="row">
		                        <div class="col-sm-4 b-r">
									<input type="file" id="upload_picture" align='center'> 
									<input type="hidden"  name="icon" id="icon" value=""/>
									<div class="image">
										<notempty name="data['path']"> 
											<img class="img-responsive" src="__ROOT__{$data['path']}"/>
										</notempty>  
									</div>
		                        </div>
		                        <div class="col-sm-8">
									<input type="file" id="upload_bigpicture" align='center'> 
									<input type="hidden"  name="bigicon" id="bigicon" value=""/>
									<div class="image">
										<notempty name="data['bigpath']"> 
											<img class="img-responsive" src="__ROOT__{$data['bigpath']}"/>
										</notempty>  
									</div>
		                        </div>
		                    </div>
	                    </form>
	                </div>
	            </div>
	        </div>
        </div>
        <div class="row">
	        <div class="col-lg-12">
	            <div class="ibox float-e-margins">
	                <div class="ibox-title">
	                    <h5>产品列表信息</h5>
	                    <div class="ibox-tools">
	                        <a class="collapse-link">
	                            <i class="fa fa-chevron-up"></i>
	                        </a>
	                    </div>
	                </div>
	                <div class="ibox-content">
	                	<div class="wrapper wrapper-content animated fadeInRight">
					        <div class="row">
					        	<volist name="_list" id="vo">
					            <div class="col-lg-4">
					                <div class="contact-box">
					                    <a title="{$vo.introduce}">
						                    <div class="col-sm-4">
						                        <div class="text-center">
						                            <img alt="image" class="img-square m-t-xs img-responsive" src="__ROOT__{$vo.path}	">
						                            <div class="m-t-xs font-bold">{$vo.productname}</div>
						                        </div>
						                    </div>
						                    <div class="col-sm-8">
						                        <p><strong>分类：</strong>{$vo.category}</p>
						                        <p><strong>品牌：</strong>{$vo.brandname}</p>
						                        <p><strong>库存：</strong>{$vo.stock}</p>
						                        <address>
						                            	<strong>描述：</strong>{$vo.introduce}<br>
						                            <a class="btn btn-white btn-xs" href="{:U('Phoneshop/editPicShow?id='.$vo['id'])}">
														<i class="fa fa-pencil text-navy"></i>&nbsp;修改
													</a>
													<a class="btn btn-white btn-xs" href="{:U('Phoneshop/deletePicShow?id='.$vo['id'])}">
														<i class="fa fa-trash text-danger"></i>&nbsp;删除
													</a>
						                        </address>
						                    </div>
						                    <div class="clearfix"></div>
					                    </a>
					                </div>
					            </div>
					            </volist>
					        </div>
		        		</div>
	                </div>
	            </div>
	        </div>
        </div>
    </div>
	<!-- 分页 -->
    <div class="page">
        {$_page}
    </div>  
</block>  
<block name="script">
	<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
    <script type="text/javascript"> 
	    /* 初始化上传插件 */
		$("#upload_picture").uploadify({
	        "height"          : 30,
	        "swf"             : "__STATIC__/uploadify/uploadify.swf",
	        "fileObjName"     : "download",
	        "buttonText"      : "上传图标(列表页面)",
	        "uploader"        : "{:U('File/uploadPicture',array('session_id'=>session_id()))}",
	        "width"           : 120,
	        'removeTimeout'	  : 1,
	        'fileTypeExts'	  : '*.jpg; *.png; *.gif;',
	        "onUploadSuccess" : uploadPicture,
	        'multi': false,
	        'onFallback' : function() {
	            alert('未检测到兼容版本的Flash.');
	        }
	    });
		function uploadPicture(file, data){
	    	var data = $.parseJSON(data);
	    	var src = ''; 
	        if(data.status){ 
	        	$("#icon").val(data.id); 
	        	src = data.url || '__ROOT__' + data.path 
	        	$("#icon").parent().find('.image').html( 
	        		'<img class="img-responsive" src="' + src + '"/>' 
	        	); 
	        	$("#path").val(data.path); 
	        } else {
	        	updateAlert(data.info);
	        	setTimeout(function(){ 
	                $(this).removeClass('disabled').prop('disabled',false);
	            },1500);
	        }
	    }
		
		
		/* 初始化上传插件 */
		$("#upload_bigpicture").uploadify({
	        "height"          : 30,
	        "swf"             : "__STATIC__/uploadify/uploadify.swf",
	        "fileObjName"     : "download",
	        "buttonText"      : "上传图片(详细页面)",
	        "uploader"        : "{:U('File/uploadPicture',array('session_id'=>session_id()))}",
	        "width"           : 120,
	        'removeTimeout'	  : 1,
	        'fileTypeExts'	  : '*.jpg; *.png; *.gif;',
	        "onUploadSuccess" : uploadBigPicture,
	        'multi': false,
	        'onFallback' : function() {
	            alert('未检测到兼容版本的Flash.');
	        }
	    });
		function uploadBigPicture(file, data){
	    	var data = $.parseJSON(data);
	    	var src = ''; 
	        if(data.status){ 
	        	$("#bigicon").val(data.id); 
	        	src = data.url || '__ROOT__' + data.path 
	        	$("#bigicon").parent().find('.image').html( 
	        		'<img class="img-responsive" src="' + src + '"/>' 
	        	);  
	        	$("#bigpath").val(data.path); 
	        } else {
	        	updateAlert(data.info);
	        	setTimeout(function(){ 
	                $(this).removeClass('disabled').prop('disabled',false);
	            },1500);
	        }
	    }
        $(document).ready(function(){
            $('.file-box').each(function() {
                animationHover(this, 'pulse');
            });
        });
	</script>	
</block>
